<template>
	<div class="registration-management">
		<el-breadcrumb style='font-size:16px;padding-bottom:10px;margin-bottom:10px;border-bottom: 1px solid #569efe;' separator="/">
		  <el-breadcrumb-item :to="{ path: '/' }">活动列表</el-breadcrumb-item>
		  <el-breadcrumb-item :to="{ path: '/activity/list/registration_list/' + actionId,query:{title:title}}">报名管理</el-breadcrumb-item>
		  <el-breadcrumb-item>报名信息</el-breadcrumb-item>
		</el-breadcrumb>
		<div class="activity-name">【{{title}}】</div>
		<div>
			<div class="main-base-info">
				<div>基本信息</div>
				<div>
					<el-button v-show='status == "已完成"' :disabled='hxstatus == 0 ? false :true' @click='handleAction'>{{hxstatus == 0 ? '手动核销' :'已核销'}}</el-button>
					<el-button type="primary" class='change-btn' @click='handleBaseInfo'>修改基本信息</el-button>
				</div>
			</div>
			<el-table
			    :data="infolist"
			    style='width:551px;margin-left:48px;margin-bottom:10px;'
			    border>
			    <el-table-column
			      label="信息"
			      width="210">
			      <template scope='scope'>
			      {{scope.row.infoname}}
			  	  </template>
			    </el-table-column>
			    <el-table-column
			      label="内容"
			      width="338">
			       <template scope='scope'>
			       	 <span v-show='infoBtn'>{{scope.row.value}}</span>
					 <el-input v-if='!infoBtn' style='width:70%;height:95%' v-model="scope.row.value" placeholder="请输入内容"></el-input>
			       </template>
			    </el-table-column>
			  </el-table>
			  <div style='margin-top:10px;text-align:center;width:580px;'>
			  <el-button  type="primary" v-show='!infoBtn' @click='saveBaseInfo'>保存</el-button>
			  <el-button  type="danger" v-show='!infoBtn' @click='saveCloseInfo'>取消</el-button>
			  </div>
		 </div>
		 <div class="main-base-info">
				<div>票种信息</div>
		</div>
		<div class="table-content">
			<div class='list-item'><span class="ticket-info-item">订单编号</span><span class="info-item">{{ordernum ? ordernum : ' - '}}</span></div>
			<div class='list-item'><span class="ticket-info-item">票种</span><span class="info-item">{{ticketTitle ? ticketTitle : ' - '}}</span></div>
			<div class='list-item'><span class="ticket-info-item">报名/付款状态</span><span class="info-item">{{status ? status : ' - '}}</span></div>
			<div class='list-item'><span class="ticket-info-item">订单时间</span><span class="info-item">{{orderdate?orderdate:' - '}}</span></div>
			<div class='list-item'><span class="ticket-info-item">签到码</span><span class="info-item">{{codes ? codes : ' - '}}</span></div>
		</div>
		<div class="go-back">
			
			<el-button type='primary' @click="$router.go(-1)">返回</el-button>
			<el-button @click='checkorder'>查看订单</el-button>
		</div>
	</div>
</template>
<script>
	export default {
		data (){
			return {
				id:this.$route.params.id,
				actionId:this.$route.query.activityId,
				infolist:null,
				returnmap:null,
				ordernum:null,
				infoBtn:true,
				title:'',
				ticketTitle:null,
				status:null,
				hxstatus:null,
				orderdate:null,
				unchangename:null,
				unchangephone:null,
				codes:null,
				hxdate:null

			}
		},
		methods:{
			handleBaseInfo(){
				this.infoBtn = false;
				this.unchangephone = this.infolist[1].value
				this.unchangename = this.infolist[0].value
			},
			saveCloseInfo(){
				this.infoBtn = true;
				this.infolist[1].value = this.unchangephone
				this.infolist[0].value = this.unchangename
			},

			saveBaseInfo(){
				this.$confirm('确定要保存此修改?', '提示', {
		          confirmButtonText: '确定',
		          cancelButtonText: '取消',
		          type: 'info'
		        }).then(() => {
		        	this.$http.post('marketweb/orderback/updateinfo',{
		        		keyAdmin:this.$store.state.keyAdmin,
		        		infolistStr:JSON.stringify(this.infolist)
		        	}).then(response=>{
		        		if(response.body.code == 200){
		        			this.$message({
				            type: 'success',
				            message: '修改成功!'
				          });
		        			this.infoBtn=true;
		        			this.getManageInfo();
		        		}else{
		        			this.$message.error(response.body.msg)
		        		}
		        	},response=>{
		        		this.$message.error('修改信息失败')
		        	})
		          
		        }).catch(() => {
		          this.$message({
		            type: 'info',
		            message: '已取消修改'
		          });          
		        });
			},

			handleAction(){
				  this.$confirm('确定手动核销此报名人提交的信息么', '提示', {
		          confirmButtonText: '确认',
		          cancelButtonText: '取消',
		          type: 'info'
		        }).then(() => {
		        	this.$http.post('marketweb/orderback/hxCodes',{
		        		keyAdmin:this.$store.state.keyAdmin,
		        		codes:this.codes
		        	}).then(response=>{
		        		if(response.body.code == 200){
		        			this.$message({
				            type: 'success',
				            message: '核销成功!'
				          });
		        		}else{
		        			this.$message.error(response.body.msg)
		        		}
		        		this.$route.go(0)
		        	})
		        }).catch(() => {
		          this.$message({
		            type: 'info',
		            message: '已取消操作'
		          });          
		        });
			},

			checkorder(){
				this.$router.push({path:'/activity/list/order_manage/'+this.$route.query.activityId ,query:{ordernum:this.ordernum}})
			},

			getManageInfo(){
				this.$http.post('marketweb/orderback/selectEnrollById',{
					keyAdmin:this.$store.state.keyAdmin,
					detailId:this.id
				}).then(response=>{
					if (response.body.code == 200) {
						this.infolist = response.body.infolist
						console.log(response)
						this.returnmap = response.body.returnmap
						this.ordernum = this.returnmap.ordernum,
						this.ticketTitle = this.returnmap.ticketTitle;
						if(this.returnmap.status == 0){
							this.status = '待审核'
						}else if(this.returnmap.status == 1){
							this.status = '未通过'
						}else if(this.returnmap.status == 2){
							this.status = '待付款'
						}else if(this.returnmap.status == 3){
							this.status = '已完成'
						}else if(this.returnmap.status == 4){
							this.status = '已核销'
						}else if(this.returnmap.status == 6){
							this.status = '已取消'
						}
						this.hxdate = this.returnmap.hxdate,
						this.codes = this.returnmap.codes,
						this.orderdate = this.returnmap.orderdate,
						this.hxstatus = this.returnmap.hxstatus;
					}else{
						this.$message.error(response.body.msg)
					}
				},response=>{
					this.$message.error('请求数据失败')
				})
			}
		},

		created(){
			this.getManageInfo()
			this.title = window.sessionStorage.title

		}
	}
</script>
<style scoped>
	.registration-management{
		padding-left: 30px;
	}
	.ticket-info-item{
		font-size: 16px;
		color: #000;
		padding: 4px;
		display: inline-block;
		width: 200px;
		text-align: center;
		border-bottom:1px solid #ddd;
		
	}

	.change-btn{
	 	padding: 8px 10px;
	}

	.info-item{
		font-size: 16px;
		color: #000;
		padding: 4px;
		display: inline-block;
		width: 334px;
		background: #fff;
		text-align: center;
		border-bottom:1px solid #ddd;
		border-right:1px solid #ddd;
	}

	.registration-management-title{
		font-size: 20px;
		color: #50a8d9;
		border-bottom: 1px solid #ddd;
		padding-left: 10px;
		padding-bottom: 10px;
	}
	.go-back{
		text-align: center;
		margin-top: 25px;
	}
	.table-content{
		width: 552px;
		margin-left: 45px;
		margin-top: 20px;
		background: #eef1f6;
		border: 1px solid #ddd;
		border-bottom: none;
		border-right: none;
	}
	.activity-name{
		font-size: 18px;
		color: #666;
		margin-left: -8px;
		padding-bottom: 10px;
		
	}
	.main-base-info{
		display: flex;
		padding-right: 20px;
		margin-top:20px;
		justify-content: space-between;
	}
	.page-pagination{
		min-width: 380px;
		float: right;
	}
</style>